import req from '@/utils/request.js';
import * as URL from '@/constants/api.js';

// 居家
export function livinghome(id) {
  return req({
    url: URL.LIVINGHOME,
    params: {
      id,
    },
  })
    .then((res) => res.data.result)
    .catch(() => {});
}

// 二级分类
// 居家茶咖酒具
export function filter(id) {
  return req({
    url: URL.SUB_FILTER,
    params: {
      id,
    },
  })
    .then((res) => ({
      ...res.data.result,
      saleProperties: res.data.result.saleProperties.map((item) => ({
        ...item,
        config: false,
      })),
    }))
    .catch(() => ({}));
}
// 图片集列表
export function subgoods(params) {
  return req({
    url: URL.SUB_GOODS,
    method: 'post',
    data: params,
  })
    .then((res) => res.data.result)
    .catch(() => ({}));
}
// 产品详情
export function product(id) {
  return req({
    url: URL.GOODS_PRDUCT,
    params: {
      id,
    },
  })
    .then((res) => res.data.result)
    .catch(() => ({}));
}
// 轮播图数据
export function subbanner(params) {
  return req({
    url: URL.SUB_BANNER_DATA,
    params,
  })
    .then((res) => res.data.result)
    .catch(() => ({}));
}
// 24小时热销榜
export function subhotsale(params) {
  return req({
    url: URL.SUB_HOT_SALE,
    params,
  })
    .then((res) => res.data.result)
    .catch(() => ({}));
}
